package org.xi.behavioral.state;

import org.xi.behavioral.state.api.PlayerState;
import org.xi.behavioral.state.states.*;

public class MusicPlayer {
    public final PlayerState PAUSED_STATE = new PausedState(this);
    public final PlayerState PLAYING_STATE = new PlayingState(this);
    public final PlayerState STOPPED_STATE = new StoppedState(this);

    private PlayerState playerState;

    public MusicPlayer() {
        this.playerState = STOPPED_STATE; // 初始状态为停止
    }

    public void setState(PlayerState playerState) {
        this.playerState = playerState;
    }

    public void play() {
        playerState.play();
    }

    public void pause() {
        playerState.pause();
    }

    public void stop() {
        playerState.stop();
    }
}